spa.grids = (function($){
    var
        configMap = {

        },Grid,getParams

    getParams = function(){
        return {}
    }

    Grid = (function($container,options){
        var
            configMap = {
                columns : options.columns,
                fields : options.fields,
                search_fields : options.search_fields,
                defaults : {
                    dom: "<'table-scrollable't><'row pagination-panel'<'col-md-2 col-sm-12'l><'col-md-4 col-sm-12'i><'col-md-6 col-sm-12'p>>",
                    processing: true,
                    serverSide: true,
                    scrollCollapse: false,
                    filter: false,
                    displayLength: 20,
                    searching: false,
                    lengthMenu: [
                        [20, 100, 150, 200, 250, 300, 400, 500, 600, -1],
                        [20, 100, 150, 200, 250, 300, 400, 500, 600, "All"]
                    ],
                    oLanguage: {
                        oAria: {
                            sSortAscending: ": 升序排列",
                            sSortDescending: ": 降序排列"
                        },
                        oPaginate: {
                            sFirst: "首页 ",
                            sLast: " 末页",
                            sNext: " 下页",
                            sPrevious: "上页 "
                        },
                        sEmptyTable: "没有相关记录",
                        sInfo: "第 _START_ 到 _END_ 条记录，共 _TOTAL_ 条",
                        sInfoEmpty: "第 0 到 0 条记录，共 0 条",
                        sInfoFiltered: "(从 _MAX_ 条记录中检索)",
                        sInfoPostFix: "",
                        sDecimal: "",
                        sThousands: ",",
                        sLengthMenu: "每页&nbsp;_MENU_&nbsp;条",
                        sLoadingRecords: "正在载入...",
                        sProcessing: "正在载入...",
                        sSearch: "搜索:",
                        sSearchPlaceholder: "",
                        sUrl: "",
                        sZeroRecords: "没有相关记录"
                    },
                    oPaginationType: "full_numbers",
                    ajax: {
                        url: options.url,
                        type: "post",
                        data: getParams()
                    },
                    aaSorting: [],
                    select : true
                },
            },stateMap,jqueryMap,initGrid,setJqueryMap
        stateMap = {
            $container : $container
        }

        jqueryMap = {
            $container : $container
        }

        setJqueryMap = function(){
            var
                $container = stateMap.$container,
                grid_html = String()
                    + '<table>'
                        + '<thead>'
                        + '</thead>'
                    + '</table>',
                $grid = $(grid_html),
                $tr = $('<tr/>'),index
            for(index in options.columns){
                $tr.append($('<td>' + options.columns[index].title + '</td>'))
            }
            $grid.find('thead').append($tr)
            $container.append($grid)
        }

        initGrid = function(){
            setJqueryMap()
        }

        initGrid()
    })

    return {
        Grid : Grid
    }
}(jQuery))